Function FileCount( Directory$ )

Local MaxFiles = 0
Local ReadingDirectory
	
	ReadingDirectory = ReadDir( Directory$ )
	
	Repeat
	
		CurrentFile$ = NextFile$( ReadingDirectory )
		
		If CurrentFile$ = "" Then Exit
				
		If FileType( Directory$ + CurrentFile$ ) = 1 Then	
			MaxFiles = MaxFiles + 1			
		End If
	
	Forever
	
	CloseDir ReadingDirectory
	
	Return MaxFiles
	
End Function